<template>
  <div id="card">
  	<header>
  		<p class="name">{{user.userNameCn}}</p>
  	</header>
  	<footer>
  		<input class="search"
               type="text"
               v-model="username"
               placeholder="请搜索用户名.."
               @change="getUsers"
               />
  	</footer>
  </div>
</template>

<script>
import utils from '../../util/util'

export default {
  name: 'card',
  data () {
    return {
        username:'',
        user: JSON.parse(window.sessionStorage.getItem('user')),
    }
  },created () {
        // this.getUsers();
        const user = this.$route.query.user
        if (user){
            let username = JSON.parse(user);
            this.username = username.userNameCn;
            this.getUsers();
            return;
        }
        this.getUsers();
    },
    methods:{
      getUsers() {
          let self = this;
          let username = self.username
          self.utils.sendReq({
              queryUrl:"/chat/admin?username="+username,
              req:{
                  method:"get",
                  success:function(req){
                      if (req.data.code === 200){
                          self.$store.state.admins = req.data.data;
                      }
                  }
              }
          })
      }
    }
}
</script>

<style lang="scss" scoped>
#card {
	padding: 12px;
  .avatar{
  	width: 40px;
  	height: 40px;
  	vertical-align: middle;/*这个是图片和文字居中对齐*/
  }
  .name {
  	display: inline-block;
  	padding: 10px;
  	margin-bottom: 15px;
  	font-size: 16px;
  }
  .search {
  	background: #26292E;
  	height: 30px;
  	line-height: 30px;
  	padding: 0 10px;
  	border: 1px solid #3a3a3a;
  	border-radius: 4px;
  	outline: none;/*鼠标点击后不会出现蓝色边框*/
    color: #FFF;
  }
}
</style>
